#coding=utf-8
'''
Created on 2013-9-3

@author: Ben

城市数据
'''

class CityVO:
    '''
    classdocs
    '''
    
    #城市id
    cityId = 0
    #城市所属
    belong = 0
    #是否可攻击
    attackable = False
    #城市状态
    state = 0

    def __init__(self, data):
        '''
        Constructor
        '''
        cityInfo = data.split("|")
        self.cityId = int(cityInfo[0])
        self.belong = int(cityInfo[1])
        self.state = int(cityInfo[2])
        self.attackable = int(cityInfo[14]) == 1
    
    '''
            更新城市
    '''
    def update(self, data):
        if "state" in data:
            self.state = data["state"]
        if "belong" in data:
            if self.belong != data["belong"]:
#                 print '城市', self.cityId, '所属由', self.belong, '变为', data["belong"]
                self.belong = data["belong"]
        if "attCity" in data:
            attackable = int(data["attCity"]) == 1
            if self.attackable != attackable:
#                 print '城市', self.cityId, '攻击状态由', self.attackable, '变为', attackable
                self.attackable = attackable